from Entity import Entity
from gordon.core import blank_map

class World(Entity):
	""" Defines a game world.
		Each instance of this object contains a multi dimensional array of
		map cordinates, each of the location can contain an infinate amount
		of objects derived from the Entity class.
	"""
	def __init__(self, _width, _height):
		""" Default constructor for the World class
		    This constructor creates a new world instance. It accepts 2 ints,
			width and height, that are used to setup the map. These numbers 
			are not constant, you can shrink and grow the map with the provided
			methods.
		"""
		Entity.__init__(self)
		self.objects = []
		self.map = blank_map(_width, _height)
		
		
	def add_object(self, _obj):
		""" Just inserts an object into the objects list without setting its position
			on the map. Dont know what this is usefull for but just maybe.
			TODO: If no global objects are needed of usefull please remove me.
		"""
		self.objects.append(_obj)
	
	def add_object_location(self, _obj, _x, _y):
		""" Insert an object and set its location on the map.
		"""
		_obj.world = self
		self.map[_y][_x].append(_obj)
		
	def get_object_id(self, _id):
		""" Get an object currently on the map by its ID. If not found return None
		"""
		pass
	
	def get_object_location(self, _x, _y):
		""" Returns a list of all objects in the specified location. If none are found
			return None
		"""
		return self.map[_y][_x]
		
	def get_object_has_attr(self, _key):
		"""	Returns all objects that have the specified key.
		"""
		pass
		
	def get_object_attr(self, _key, _value):
		""" Returns all objects that match the {_key: _value} pair.
		"""
		pass
		
	